package dbutil

import (
	"BingWallpaper/entity"
	"BingWallpaper/logger"

	"database/sql"

	_ "github.com/mattn/go-sqlite3"
)

//查找记录是否存在
func recordExists(bing entity.Bing) bool {
	db, err := sql.Open("sqlite3", "./Database/bing.db")
	if err != nil {
		logger.Loginfo(err.Error())
	}

	var hsh string
	//查询数据
	errnew := db.QueryRow("SELECT hsh FROM detail where hsh=?", bing.Images[0].Hsh).Scan(&hsh)
	db.Close()
	if errnew != nil {
		if errnew != sql.ErrNoRows {
			logger.Loginfo(errnew.Error())
		}
		return false
	}
	return true
}
